package guowei.guliproduct.product.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * 通过使用MyBatis-Plus分页插件，
 * 您可以指定页面大小(每页记录数)和当前页码来获取相关数据。然后，插件生成必要的SQL查询，仅从数据库中检索所需的数据部分。
 *
 * 只有开启了EnableTransactionManagement注解才能使用事务功能
 */
@Configuration
@EnableTransactionManagement
@MapperScan("guowei/guliproduct/product/dao")
public class MybatisPlusPage {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        return interceptor;
    }
}
